/*
 *  image.h
 *  Ray Tracer
 *  Functions and struct to read and write binary PortablePixMaps (PPMs).
 *
 *  Created by Chirantan Ekbote on 9/8/10.
 *  Copyright 2010 Ohio State University. All rights reserved.
 *
 */

#ifndef _IMAGE_H_
#define _IMAGE_H_

#ifdef  __cplusplus
extern "C" {
#endif	// __cplusplus
	
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include "rgb.h"

typedef struct image {
	rgb** raster;	// Stored such that pixel(0,0) is at the bottom left
	int x;			// raster width
	int y;			// raster height
} image;

image imageInit(int width, int height);

image imageBackgroundInit(int width, int height, const rgb* background);

int imageSetPixel(image* pix, int x, int y, const rgb* color);

void imageGammaCorrect(image* pix, float gamma);

// writes image as ppm
void imageWritePPM(const image* pix, const char* filename);

// reads in a binary ppm
void imageReadPPM(image* pix, const char* filename);
#ifdef  __cplusplus
}
#endif	// __cplusplus
#endif // _IMAGE_H_